const { User } = require('../../model/user');
module.exports = async (req,res)=>{
  //根据传入过来的id查找用户
  let user = await User.findOne({_id: req.query.id});
  //查找到
  if(user){
    if(user.state == 1){
      await User.findByIdAndUpdate(req.query.id,{
        state: 0
      });
      res.redirect('/admin/toUserList');
    }else if (user.state == 0){
      await User.findByIdAndUpdate(req.query.id,{
        state: 1
      });
      res.redirect('/admin/toUserList');
    }
  }
  res.send('ok');
}